package org.example;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-10-19
 * 15:23
 */
public class Test {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
           String s=sc.nextLine();
           int sum=0;
           if(s.equals("0")){
               break;
           }
            for (int i = 0; i < s.length(); i++) {
                char c=s.charAt(i);
                String ss=String.valueOf(c);
                int k=Integer.parseInt(ss);
                sum+=k;
            }
            System.out.println(sum);
        }
    }
}
